import React, {useRef} from 'react'
import {Card} from 'antd'
import {GridContent} from '@ant-design/pro-layout';
import ProTable from '@ant-design/pro-table'
import moment from 'moment';
import {queryScorePage} from '../service';

const Score = ({oid}) => {
  const actionRef = useRef();
  const columns = [
    {
      title: '序号',
      render: (text, record, index) => `${index + 1}`,
      hideInSearch: true,
    },
    {
      title: '评分时间',
      dataIndex: 'createTime',
      hideInSearch: true,
      render: (text) => {
        return text !== '-' ? moment(text).format('YYYY-MM-DD') : ''
      },
    },
    {
      title: '原因',
      hideInSearch: true,
      dataIndex: 'programName',
    },
    {
      title: '分数',
      hideInSearch: true,
      dataIndex: 'score',
    },
    {
      title: '是否及格',
      hideInSearch: true,
      render: (text, record) => {
        return record.score >= 80 ? '是' : '否';
      },
    },
  ];

  return (
    <>
      <GridContent>
        <Card title="360评分" style={{marginBottom: 24}} bordered={false}>
          <ProTable
            actionRef={actionRef}
            rowKey="id"
            request={(params) => queryScorePage(params, oid)}
            columns={columns}
            search={false}
            options={false}
            toolBarRender={false}
          />
        </Card>
      </GridContent>
    </>
  );
};
export default Score;
